<#assign ctx="${rc.contextPath}">
<html>
<head>
    <title>修改密码</title>
    <script type="text/javascript">
        function changePwd() {
            var pwd = $('#pwd');
            var pwdTwo = $('#pwdTwo');
            if(pwd.val() == "" || pwd.val() == null){
                $("#textSpan").text("密码不能为空");
                return;
            }
            var reg = "(?=.*[a-z].*)(?=.*[A-Z].*)(?=.*[\\d].*)(?=.*[\\~\\!\\@\\#\\￥\\%\\…\\&\\*\\（\\）\\^\\$\\-\\_\\！\\.\\[\\]\\{\\}\\=\\+\\|\\,\\<\\>\\?\\？\\/\\《\\》\\;\\:\\'\"\\`].*).{8,}";
            if (pwd.val().match(reg) == null){
                $("#textSpan").text("密码必须同时包括大小写字母、数字、特殊符号8 位以上");
                return;
            }
            if (pwd.val() != pwdTwo.val()) {
                $("#textSpan").text("两次密码不一致");
                return;
            }
            $.messager.confirm('确认', '是否修改密码?', function (r) {
                if (r) {
                    $.post('${ctx}/login/changPwd',
                            {
                                'password': pwd.val()
                            },
                            function (msg) {
                                if (msg == "密码必须同时包括大小写字母、数字、特殊符号8 位以上"){
                                    $("#textSpan").text("密码必须同时包括大小写字母、数字、特殊符号8 位以上");
                                    return;
                                }
                                successMsg(msg);
                                if (msg == "修改成功！") {
                                    window.location.href = "${ctx}/login/logout";
                                }
                            });
                }
            });
        }
        function isNum(str) {
            var n = Number(str);
            if (!isNaN(n)) {
                return true;
            }
            return false;
        }
        function cancel() {
            window.history.go(-1);
        }
        function clearText() {
            $("#textSpan").text("");
        }
    </script>
</head>

<body>
<div class="breadcrumb">基础信息 > 用户设置 > 修改密码</div>

<form class="form-horizontal form-edit">
    <div class="form-item">
        <div class="form-lab">新密码：</div>
        <div class="form-field">
            <span class="must">*</span>
            <input class="easyui-validatebox text" type="password" id="pwd" name="pwd" onmousedown="clearText()"
                   data-options="required:true"/>
        </div>
    </div>
    <div class="form-item">
        <div class="form-lab">确认密码：</div>
        <div class="form-field">
            <span class="must">*</span>
            <input class="easyui-validatebox text" type="password" id="pwdTwo" name="pwdTwo" onmousedown="clearText()"
                   data-options="required:true"/>
            <div><span id='textSpan' class='must' style="padding-left: 9px;"></span></div>
        </div>
    </div>

    <div class="form-item">
        <div class="form-lab">&nbsp;</div>
        <div class="form-field">
            <input class="btn btn-primary" type="button" onclick="changePwd()" value="保存"/>
            <input class="btn" type="button" onclick="cancel()" value="取消"/>
        </div>
    </div>
</form>
</body>
</html>
